| Objective | Complete |
|---|---|
| Describe bivariate plots and multivariate plots in Plotly | |
| Save plots in Plotly |
plotly express packageIris flower dataset is a multivariate data set introduced by the British statistician and biologist Ronald Fisher in his 1936 paper The use of multiple measurements in taxonomic problems.The dataset contains a set of 150 records under 5 attributes
plotly express:# Load the iris dataset from `plotly express`
iris_dataset = px.data.iris()
# Top 5 entries of the dataset
iris_dataset.head() sepal_length sepal_width petal_length petal_width species species_id
0 5.1 3.5 1.4 0.2 setosa 1
1 4.9 3.0 1.4 0.2 setosa 1
2 4.7 3.2 1.3 0.2 setosa 1
3 4.6 3.1 1.5 0.2 setosa 1
4 5.0 3.6 1.4 0.2 setosa 1
A bivariate plot is a plot that allows us to identify the relationship between two variables
plotly express has various bivariate plots available:
We are going to discuss a subset of these
For each of these plots, we will be using in-built datasets from the plotly express package
# Construct a scatter plot by simply giving the plotting function scatter
fig = px.scatter(iris_dataset,
x='sepal_length',
y='petal_length',
color='species',
size='sepal_width')
fig.show()symbol argumentfig = px.scatter(iris_dataset,
x='sepal_length',
y='petal_length',
color='species',
size='sepal_width',
symbol='species')
fig.show()plotly Express lets us create a linear regression for each of our groupings and see the model summary for each of those as well# Create and save model summary
results = px.get_trendline_results(fig)
# Access the model parameters
results.query("species=='setosa'").px_fit_results.iloc[0].summary()Instead of just checking the relationship between two variables, maybe we want to look at the relationship between multiple pairs of variables. We can do that with plotly express as well
Here are the types available:
We’ll be discussing scatter matrix plot in next slides
| Objective | Complete |
|---|---|
| Describe bivariate plots and multivariate plots in Plotly |
✔ |
| Save plots in Plotly |
plotly express, we simply need the variable we saved the plot to
| Objective | Complete |
|---|---|
| Describe bivariate plots and multivariate plots in Plotly |
✔ |
| Save plots in Plotly |
✔ |
You are now ready to try Tasks 4-8 in the Exercise for this topic